package com.monolithiot.notifier.conf;

import com.monolithiot.notifier.conf.prop.YunPianConfigureProperties;
import com.yunpian.sdk.YunpianClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * 2018/12/22 Create by 郭文梁
 * YunPianClientConfigure
 * 云片客户端配置
 *
 * @author 郭文梁
 * @date 2018/12/22
 */
@Configuration
@Component
public class YunPianClientConfigure {
    private final YunPianConfigureProperties yunPianConfigureProperties;

    @Autowired
    public YunPianClientConfigure(YunPianConfigureProperties yunPianConfigureProperties) {
        this.yunPianConfigureProperties = yunPianConfigureProperties;
    }

    /**
     * 配置注册YunPianClient
     *
     * @return 云片API客户端
     */
    @Bean
    public YunpianClient yunpianClient() {
        return new YunpianClient(yunPianConfigureProperties.getApiKey())
                .init();
    }
}
